/**
 * 扩展 easyui 的 layout 控件
 */

(function($){

    var regions=["north","south","west","east"];

    $.extend($.fn.layout.methods,{
        toggle:function(jq,region){
            return jq.each(function(){
                var $layout=$(this);
                var $panel=$layout.layout("panel",region);
                var options=$panel.panel("options");
                if(options.collapsed){
                    $layout.layout("expand", region);
                }else{
                    $layout.layout("collapse", region);
                }
            });
        },
        collapseAll:function(jq){
            return jq.each(function(){
                var $layout=$(this);
                $.each(regions,function(index,value){
                    $layout.layout("collapse",value);
                });
            });
        },
        expandAll:function(jq){
            return jq.each(function(){
                var $layout=$(this);
                $.each(regions,function(index,value){
                    $layout.layout("expand",value);
                });
            });
        },
        toggleAll:function(jq){
            return jq.each(function(){
                var $layout=$(this);
                $.each(regions,function(index,value){
                    $layout.layout("toggle",value);
                });
            });
        }
    });

})(jQuery);

